package com.ttai.presenter.activity;

import android.content.Intent;
import android.widget.Toast;

import com.google.gson.JsonObject;
import com.ttai.model.net.ResponseInfo;
import com.ttai.presenter.base.BasePresenter;
import com.ttai.ui.activity.AddIdAcount;
import com.ttai.ui.activity.LoginId;

import retrofit2.Call;

public class TaiRegiserPresenter extends BasePresenter{
    AddIdAcount addIdAcount;

    public TaiRegiserPresenter(AddIdAcount addIdAcount) {
        this.addIdAcount = addIdAcount;
    }

    @Override
    protected void showError(String message) {
        Toast.makeText(addIdAcount,message,Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void parseJson(JsonObject json) {
        Toast.makeText(addIdAcount,"一键注册成功",Toast.LENGTH_SHORT).show();
        addIdAcount.finish();
        Intent intent=new Intent();
        intent.setClass(addIdAcount,LoginId.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);//关掉所要到的界面中间的activity
        addIdAcount.startActivity(intent);
    }
    public void regiser(String token,String appId){
        Call<ResponseInfo> regiserInfo = responseInfoApi.taiRegiser(token, appId);
        regiserInfo.enqueue(new CallBackAdapter());
    }
}
